//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#ifndef NATIVE_SYSTEM_BASE_ZEROVALUEEXCEPTION_H
#define NATIVE_SYSTEM_BASE_ZEROVALUEEXCEPTION_H

#ifndef NATIVE_SYSTEM_BASE_EXCEPTION_H
#include "System/Base/Exception.h"
#endif

namespace Native { namespace System
{
    //****************************************************************************************************************//
    //CZeroValueException
    //
    //****************************************************************************************************************//
    template<typename _TNumeric>
    class NATIVE_LIBRARY_EXPORT CZeroValueException
        :public CException
    {
        NATIVE_DECLARE_OBJECT;

        NATIVE_REDEFINE(public, _TNumeric, TNumeric, T_NUMERIC);
        NATIVE_REDEFINE(public, CZeroValueException<TNumeric>, Class, CLASS);

    public:
        static void Check(
            C_SCENE& scene,
            TNumeric checked,
            WSTRING& arguments = EMPTY_STRING,
            WSTRING& detail = EMPTY_STRING) throw()
        {
            if (checked == 0) {
                throw CZeroValueException<TNumeric>(scene, arguments, detail);
            }
        }

    protected:
        CZeroValueException()
        {};

    public:
        CZeroValueException(CLASS& that) :
            CException(that)
        {};

        CZeroValueException(CLASS&& that) :
            CException(that)
        {};

        CZeroValueException(
            C_SCENE& scene,
            WSTRING& arguments = EMPTY_STRING,
            WSTRING& detail = EMPTY_STRING)
        {
            Append(CCase(scene, L"0 is a forbidden value", arguments, detail));
        };
    };
}}

#endif